package com.example.testdemo.h5_to_app;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.TextView;

import com.example.testdemo.R;

/**
 * Created by 颜 on 04.11.011.
 * 隐式意图Intent
 */

public class H5ToAppActivity extends Activity {
    private String key;
    private TextView textView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_h5_to_app);
        initData();
        initView();
        initIntent();
    }

    private void initData() {
        key = "json";
    }

    private void initView() {
        textView = findViewById(R.id.textView);
    }

    private void initIntent() {
        Uri uriData = this.getIntent().getData();
        assert uriData != null;
        String data = uriData.getQueryParameter(key);
        if (TextUtils.isEmpty(data)){
            textView.setText("啥也没收到");
        }else {
            textView.setText(data);
        }
    }
}
